<?php
declare(ENCODING = 'utf-8');

/*
 * phpCR_ValueFactoryInterface.php created on 14 avr. 08 
 * Author: Rodrigue Le Gall
 * 
 * This file is inspired by the project phpCR of Travis Swicegood <development@domain51.com>
 *
 * RPortal is an open source web based Content Management System
 * Copyright (C) 2002-2008  Rodrigue Le Gall
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

/**
 * A ValueFactory interface
 *
 * The ValueFactory object provides methods for the creation Value objects that can
 * then be used to set properties.
 *
 * @package phpContentRepository
 * @RPInterface
 */
interface phpCR_ValueFactoryInterface {

	/**
	 * Returns a Value object with the specified value. If $type is given,
	 * conversion is attempted before creating the Value object.
	 * 
	 * If no type is given, the value is stored as is, i.e. it's type is
	 * preserved. Exceptions are:
	 * * if the given $value is a Node object, it's UUID is fetched for the
	 *   Value object and the type of that object will be REFERENCE
	 * * if the given $value is a file pointer, the file's content will be
	 *   fetched for the Value object. The file pointer will be closed before
	 *   returning the Value object. The Value object will be of type BINARY.
	 * * if the given $Value is a DateTime object, the Value type will be DATE.
	 * 
	 * @param mixed $value
	 * @param integer $type
	 * @return phpCR_ValueInterface
	 * @throws phpCR_ValueFormatException is thrown if the specified value cannot be converted to the specified type.
	 * @throws phpCR_RepositoryException if the specified Node is not referenceable, the current Session is no longer active, or another error occurs.
	 */
	public function createValue($value, $type = NULL);

}
